﻿@{
    ViewBag.Title = "Thêm thông tin hữu ích";
    Layout = "~/Views/Shared/_Admin.cshtml";
}
@model VisaApp.Models.ThongtinhuuichModel
@{  AjaxOptions ajaxOpts = new AjaxOptions
    {
        HttpMethod = "post",
        OnComplete = "completedAjaxRequestCustoer"
    };
}
<script type="text/javascript">
    
    $(document).ready(function () {

        $("#tabasAddCategory").tabs();
        onSelectlistCategory();
        var editor = CKEDITOR.instances['ckeditor'];
        if (editor) { editor.destroy(true); }
        CKEDITOR.replace('ckeditor', {
            filebrowserImageUploadUrl: '/News/UploadImage',
            height: "300"
        });

    });

    function onSelectlistCategory() {
        var ids = $("#selectKhuVuc").val();
        $("#Regioncode").val(ids);
        $.getJSON("/Visa/AllQuocGiaByCateid/" + ids,
            function (carData) {
                var select = $("#selectProduct");
                select.empty();
                $.each(carData, function (index, itemData) {
                    select.append($('<option/>', {
                        value: itemData.Value,
                        text: itemData.Text
                    }));
                });
                var name = carData[0].Value;
                $("#QuocGia").val(name);
            });
    }

    function OnSelectProduct() {
        var txt = $("#selectProduct option:selected").val();
        $("#QuocGia").val(txt);

    }
    
</script>
@using (Ajax.BeginForm("Addthongtinhuuich", "Quantri", null, ajaxOpts, new { enctype = "multipart/form-data" }))
{
    <div class="section-header">
        <div class="options">
            <a href="/Quantri/Indexthongtinhuuich">Trở về danh sách thông tin hữu ích</a>
            <button type="submit" name="save" value="save" class="t-button">
                Save</button>
        </div>
    </div>
    <div id="tabasAddCategory">
        <ul>
            <li><a href="#tabs-1">Thông tin</a></li>
            <li><a href="#tabs-2">Seo</a></li>
        </ul>
        <div id="tabs-1">
            <table>
                <tr>
                    <td colspan="2">
                        @Html.HiddenFor(model => model.Regioncode, new { id = "Regioncode" })
                         @Html.HiddenFor(model => model.Id, new { id = "Id" })
                        @Html.HiddenFor(model => model.DateCreate)
                        @Html.HiddenFor(model => model.Detele)
                        @Html.HiddenFor(model => model.QuocGia, new { id = "QuocGia" })
                        <div class="warning-area">
                        </div>
                    </td>
                </tr>
                <tr>
                    <td class="adminTitle">
                        @Html.LabelFor(model => model.Name, "Tiêu đề"):
                    </td>
                    <td class="adminData">
                        @Html.TextBoxFor(model => Model.Name, new { @style = "width:500px" })
                        @Html.ValidationMessageFor(model => model.Name)
                    </td>
                </tr>
                 <tr>
                    <td class="adminTitle">
                        Chọn Khu Vực :
                    </td>
                    <td class="adminData">
                        <select id="selectKhuVuc" onchange = "onSelectlistCategory()">
                            <option value="142">Châu Á</option>
                            <option value="150">Châu Âu</option>
                            <option value="009">Châu Đại Dương</option>
                            <option value="002">Châu Phi</option>
                            <option value="019">Bắc Mỹ</option>
                            <option value="300">Nam Mỹ</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td class="adminTitle">
                        @Html.LabelFor(model => model.QuocGia, "Bài viết thuộc về quốc gia"):
                    </td>
                    <td class="adminData">
                       <select id="selectProduct" class="selectProduct" onchange="OnSelectProduct()">
                        </select>
                    </td>
                </tr>
                <tr>
                    <td class="adminTitle">
                        @Html.LabelFor(model => model.Description, " Mô tả"):
                    </td>
                    <td class="adminData">
                        @Html.TextAreaFor(model => model.Description, new { @style = "width:500px; height:100px" })
                        @Html.ValidationMessageFor(model => model.Description)
                    </td>
                </tr>
                <tr>
                    <td class="adminTitle">
                        @Html.LabelFor(model => model.DescritpionFull, "Nội dung"):
                    </td>
                    <td class="adminData">
                        @Html.TextAreaFor(model => model.DescritpionFull, new { @cols = "10", @class = "ckeditor", @rows = "30", @id = "ckeditor" })
                        @Html.ValidationMessageFor(model => model.DescritpionFull)
                    </td>
                </tr>
                <tr>
                    <td class="adminTitle">
                        @Html.LabelFor(model => model.Status, "Trạng thái tin"):
                    </td>
                    <td class="adminData">
                        @Html.EditorFor(x => x.Status, new { @style = "width:600px" })
                        @Html.ValidationMessageFor(model => model.Status)
                    </td>
                </tr>
            </table>
        </div>
        <div id="tabs-2">
            <div style="padding: 10px">
                <h2>
                    Seo</h2>
            </div>
            <table>
                <tr>
                    <td class="adminTitle">
                        @Html.LabelFor(model => model.MetaTitle, "Meta Title"):
                    </td>
                    <td class="adminData">
                        @Html.TextBoxFor(model => Model.MetaTitle, new { @style = "width:600px; height:50px" })
                        @Html.ValidationMessageFor(model => model.MetaTitle)
                    </td>
                </tr>
                <tr>
                    <td class="adminTitle">
                        @Html.LabelFor(model => model.Keywork, "Key Work"):
                    </td>
                    <td class="adminData">
                        @Html.TextBoxFor(x => x.Keywork, new { @style = "width:600px; height:50px" })
                        @Html.ValidationMessageFor(model => model.Keywork)
                    </td>
                </tr>
                <tr>
                    <td class="adminTitle">
                        @Html.LabelFor(model => model.metaDescription, "Meta Description"):
                    </td>
                    <td class="adminData">
                        @Html.TextBoxFor(x => x.metaDescription, new { @style = "width:600px; height:50px" })
                        @Html.ValidationMessageFor(model => model.metaDescription)
                    </td>
                </tr>
            </table>
        </div>
    </div>
   
}
